﻿using System;
using System.Data;
using VitCode.Castle.Helper;

namespace CRS.Web.Reports
{
    public partial class SellReport : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Session["SellSource"] = null;
                GridView1.DataSource = DataSource;
                GridView1.DataBind();
            }
        }

        private DataTable DataSource
        {
            get
            {
                if (Session["SellSource"] == null)
                {
                    Session["SellSource"] = InitData();
                }
                return (DataTable)Session["SellSource"];
            }
        }

        private object InitData()
        {
            var table = new DataTable();
            table.Columns.Add("日期");
            table.Columns.Add("星期");
            table.Columns.Add("房费");
            table.Columns.Add("赠送金额");
            table.Columns.Add("付费金额");
            table.Columns.Add("实际支出");
            table.Columns.Add("实际收入");
            table.Columns.Add("利润");
            table.Columns.Add("清单");
            var date = DateTime.Now;
            for (int i = 0; i < 10; i++)
            {
                DataRow row = table.NewRow();
                row["日期"] = DateTime.Now.AddDays(i).ToString("yyyy-MM-dd HH:mm:ss");
                row["星期"] = EnumTypeHelper.GetWeekDayName(row["日期"].ToString());
                row["房费"] = (i + 100).ToString();
                row["赠送金额"] = (i * 0.125 + 50 * 1.25).ToString();
                row["付费金额"] = (i * 25 + 50 * 2).ToString();
                row["实际支出"] = (i * 13.56 + 50 * 1.6).ToString();
                row["实际收入"] = (i * 27.25 + 500 * 4.25).ToString();
                row["利润"] = string.Format("{0:C2}", (Convert.ToDouble(row["实际收入"]) - Convert.ToDouble(row["实际支出"])));
                var ss = Convert.ToDouble(row["利润"].ToString().Replace("￥", ""));
                //lblTotal.Text = (Convert.ToDouble(lblTotal.Text) + ss).ToString();
                table.Rows.Add(row);
            }
            //lblTotal.Text = lblTotal.Text + "元";
            return table;
        }
    }
}
